﻿using System;
using System.Collections.Generic;
using System.Text;

namespace IllustratedCsharp7_ch18Generic_Delegatge
{
    delegate void MyDelegate<T>(T value);       //泛型委托
    class Simple
    {
        static public void PrintString(string s) //方法匹配委托 
        {
            Console.WriteLine(s);
        }
        static public void PrintUpperString(string s) //方法匹配委托
        {
            Console.WriteLine($"{s.ToUpper()} ");
        }

        static public void PrintIntValue(int intval) //方法匹配委托
        {
            Console.WriteLine(intval);
        }
    }

    class GenericDeleagte
    {
        static void _Main()
        {
            var myDel = new MyDelegate<string>(Simple.PrintString);
            myDel += Simple.PrintUpperString;
            myDel("Hi There");

           var myIntDel = new MyDelegate<int>(Simple.PrintIntValue);
            myIntDel(12);
        }
    }
}
